package com.admin.service;

import com.data.entity.Database;
import com.data.mapper.DatabaseMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DatabaseService  {
    @Resource
    private DatabaseMapper databaseMapper;

    public List<Database> listPage(Integer page, Integer limit) {
        if(page>0){
            page=(page-1)*limit;
        }
        return databaseMapper.listPage(page,limit);
    }

    public int count() {
        return databaseMapper.count();
    }

    public Database getInfo(Long id) {
        return databaseMapper.selectById(id);
    }

    public int add(Database database) {
        return databaseMapper.insert(database);
    }

    public int delete(Long id) {
        return databaseMapper.deleteById(id);
    }

    public int edit(Database database) {
        return databaseMapper.updateById(database);
    }
}
